package com.ff.ticket.service.impl;

import com.ff.ticket.domain.User;
import com.ff.ticket.repository.UserRepository;
import com.ff.ticket.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService implements IUserService {

    @Resource
    private UserRepository userRepository;

    @Override
    public User findUserByName(String name) {
        return userRepository.findUserByName(name);
    }

    @Override
    public User findUserById(String id) {
        return userRepository.findUserById(id);
    }

    @Override
    public User findUserByAccount(String account) {
        return userRepository.findUserByAccount(account);
    }

    @Override
    public User updateUser(User user) {
        return userRepository.save(user);
    }

    @Override
    public void setUserRolesByAccount(String account, List<String> list) {

    }

    @Override
    public void setUserRolesByName(String name, List<String> list) {

    }

    @Override
    public List<User> findUsersByGroup(String group) {
        return userRepository.findUsersByRole(group);
    }

    @Override
    public List<User> findUsersByTag(String tag) {
        return userRepository.findUsersByTag(tag);
    }

    @Override
    public List<User> findUsersByGroupAndTag(String role, String tag) {
        return userRepository.findUsersByGroupAndTag(role,tag);
    }

    @Override
    public void deleteUser(User user) {
        userRepository.delete(user);
    }
}
